package com.ymkj.testdemo.thread;

public class TestThread {
    public static void main(String[] args) throws InterruptedException {
//        for (int i = 0; i < 1000; i++) {
//            ThreadPool.getInstance().start(new Runnable() {
//                @Override
//                public void run() {
//                    try {
//                        //休眠100ms
//                        Thread.sleep(100);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                }
//            });
//        }
        TestThreadMethod t = new TestThreadMethod("TTTTTTTTTT");
        t.setPriority(Thread.MIN_PRIORITY);
        t.start();
        for (int i = 0; i < 24; i++) {
            TestThreadMethod testThreadMethod = new TestThreadMethod("t" + i);
            testThreadMethod.setPriority(Thread.MAX_PRIORITY);
            testThreadMethod.start();
        }

    }



}

class TestThreadMethod extends Thread {
    //public static int shareVar = 0;

    public TestThreadMethod(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + ":" + i);
            Thread.yield();
            /* （2） */
//            try {
//                Thread.sleep(0);
//            } catch (InterruptedException e) {
//                System.out.println("Interrupted");
//            }
        }
    }
}
